package {
import org.flixel.*;
    // Overall level terrain
    public class LockedDoor extends FlxSprite {
    
        // Art for LockedDoor
		[Embed(source="lockeddoor.png")]
		private var lockedDoorSprite:Class;
        
        private var _Id: Number;
        private var _Locked: Boolean;
    
        public function LockedDoor(X:Number, Y:Number, Id:Number, locked:Boolean) {
            // Create sprite at coordinate X, Y
            super(X, Y);
          
            _Id = Id;
            _Locked = locked;
			
			solid = _Locked;
            
            immovable = true;
            
			loadGraphic(lockedDoorSprite, true, true, 20, 80, false);
            //makeGraphic(10, 20, 0xff000000);
			
			addAnimation("locked", [0]);
			addAnimation("unlocked", [1]);
            
            if (_Locked) {
				play("locked");
			} else {
				play("unlocked");
			}
        }
        
        public function getId():Number {
            return _Id;
        }
        
        public function toggleLock():void {
            _Locked = !_Locked;
            triggerAnimation();
            
        }
		
		public function triggerAnimation():void {
			if (_Locked) {
				play("locked");
			} else {
				play("unlocked");
			}
		}
        
        public function isLocked():Boolean {
            return _Locked;
        }
        
        override public function update():void {
            
        }
    }
}